
/**
 * @desc 赛事列表-后勤管理，新增接送站弹框
 * @author yd_zhaorongjun
 */
<template>
  <div>
    <el-dialog
      title="添加接送地"
      class="gl_dialog_TitleLine gl_dl_footer"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="440px"
    >
      <el-scrollbar v-loading="loading" wrap-class="scrollbar-wrapper gl_dialog_height" style="max-height:400px">
        <div v-if="dialogVisible">
          <el-table :data="tableData" class="gl_table_noBorder" size="mini" style="width: 100%;" @selection-change="selection">
            <el-table-column type="selection" label-class-name="selection" width="40" />
            <el-table-column
              label="接送地点"
              align="left"
            >
              <template slot-scope="{row}">
                {{ `${row.departureStation} -- ${row.arrivalStation}` }}
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-scrollbar>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
        <!-- 保存按钮 -->
        <el-button type="primary" :loading="submitLoading" :disabled="SelectionList.length <= 0" size="mini" @click="saveNew()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  SiSTKWEventsManagementPickUpAddressDto
} from '@/lib/form/game/swaggerForm';
import {
  api_GET_EventsManagementReceptionUnusedPickUpAddress
} from '@/extend/api/gameswaggerApi/app';
// import { CopyData } from '@/lib';

export default {
  data() {
    return {
      api_GET_PickUpAddressDto: new SiSTKWEventsManagementPickUpAddressDto(),
      title: '',
      loading: false,
      submitLoading: false,
      dialogVisible: false,
      editId: '',
      SelectionList: [], // 选中的数据
      tableData: []
    };
  },
  created() {
    this.gameId = this.$route.params.id;
  },
  methods: {
    open(row, categoryId) {
      console.log(row);
      this.SelectionList = [];
      this.tableData = [];
      this.dialogVisible = true;
      this.api_GET_PickUpAddressDto = new SiSTKWEventsManagementPickUpAddressDto();
      this.refreshList();
    },
    // 刷新列表
    refreshList(page) {
      this.loading = true;
      api_GET_EventsManagementReceptionUnusedPickUpAddress({ providerKey: this.gameId }).then(res => {
        console.log(res);
        this.tableData = res || [];
        // this.totalPage = res.totalCount;
        this.loading = false;
      }, error => {
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
        this.loading = false;
      });
    },
    // 选中的数据
    selection(val) {
      this.SelectionList = val;
    },
    // 新增
    saveNew() {
      this.submitLoading = true;
      const returnData = this.SelectionList.map(item => item.id);
      this.$emit('insert', returnData);
    }
  }
};
</script>
